package com.yjy.moudle_pair;

import android.text.Html;
import android.webkit.WebView;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.yjy.mybase.activity.MVPBaseActivity;
import com.yjy.mybase.http.ICallback;
import com.yjy.mybase.http.SuperHttpHelper;
import com.yjy.mybase.model.BaseBean;
import com.yjy.mybase.mvp.MVPBasePresenter;
import com.yjy.mybase.utils.ARouterUri;
import com.yjy.mybase.utils.LogUtils;

import java.util.HashMap;
import java.util.Map;

/**
 * author : yangjinyang
 * create : 2020/12/1
 * description :
 */
@Route(path = ARouterUri.ACTIVITY_NEWSDETAIL)
public class NewsDetailsActivity extends MVPBaseActivity {

    private TextView tvTitle;
    private WebView webview;

    @Override
    public MVPBasePresenter createPresenter() {
        return null;
    }

    @Override
    public int layout() {
        return R.layout.activity_news_detail;
    }

    @Override
    public void initView() {
        tvTitle = findViewById(R.id.tv_detail_title);
        webview = findViewById(R.id.tv_detail_content);


    }

    @Override
    public void initData() {
        String id = getIntent().getStringExtra("id");
        Map<String, String> pram = new HashMap<>();
        pram.put("id", "" + id);
        SuperHttpHelper.superHttpHelper().get(SuperHttpHelper.DetailInfo, pram, new ICallback<BaseBean<NewsDetailBean>>() {

            @Override
            public void onSuccess(BaseBean<NewsDetailBean> data) {
                LogUtils.e("title---->" + data.getResult().getTitle());
                tvTitle.setText(data.getResult().getTitle());

                webview.loadData(data.getResult().getContent(), "text/html", null);

            }

            @Override
            public void onFail(int errCode, String errMsg) {
                toast(errMsg);


            }
        });

    }
}
